package com.nj.api.web.controller;

import com.nj.api.entity.User;
import com.nj.api.service.AccountService;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.math.BigDecimal;

@RestController
@CrossOrigin
@RequestMapping("/account")
public class AccountController {
    @Resource
    private AccountService accountService;
    @Resource
    private RedisTemplate redisTemplate;
    @GetMapping("/getBalance")
    public BigDecimal getBalance(@RequestHeader String token){
        User user = (User) redisTemplate.opsForValue().get(token);
        return accountService.getBalanceByUid(user);
    }


}
